package com.asiainfo.nacos.demos.nacosconfig;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Component
@RestController
@RefreshScope
public class ConfigController {

    @Value("${user.name}")
    private String userName;

    @Value("${user.age}")
    private int userAge;

    @GetMapping("/userInfo")
    public String getUserInfo() {
        return "User Name: " + userName + ", Age: " + userAge;
    }
}